﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using QSAspMvc.Data;
using QSAspMvc.Models;

namespace QSAspMvc
{
	public class CustomValidationMethods
	{
		public static bool RequireUniqueProductId(object objectToTest, object context)
		{
			var productRepository = new SessionProductRepository();
			var matchingProducts = productRepository
				.GetProducts()
				.Where(x => x.ProductName == objectToTest)
				.ToArray();

			return matchingProducts.Length <= 0;
		}
	}
}
